using System;
using FireStarter.Base;
using FireStarterModeller.BO;
using Habanero.Base.Exceptions;
using NUnit.Framework;

namespace FireStarterModeller.Test.BO
{
    /// <summary>
    /// Provides a place to write custom tests for UITypeDefinition objects.
    /// This file is only written once and can be changed.  The Def file
    /// attached to this as a dependent is rewritten with each regeneration
    /// and contains the standard tests for UITypeDefinition.
    /// Regenerate this test project whenever there have been changes to the
    /// business objects.
    /// If tests are failing due to a unique setup in your application,
    /// you can either override the Create methods in TestUtils, or you
    /// can add the test to the ignore list below and reimplement it here.
    /// </summary>
    public partial class TestUITypeDefinition
    {
//        [TestFixtureSetUp]
//        public void SetupTestFixture()
//        {
//            //------------------------------------------------------------
//            // Use this list to ignore generated tests that are failing
//            // due to a unique condition in your application.
//            // Remember to reimplement the test here.
//            //------------------------------------------------------------
//            //_ignoreList.Add("TestMethodName", "Reason for ignoring it");
//        }
//        
        [Ignore("Need to implement ToString")] //TODO Brett 30 Mar 2009: Ignored Test - Need to implement ToString
        [Test]
        public void Test_ToString()
        {
            //---------------Set up test pack-------------------

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------

            //---------------Test Result -----------------------
            Assert.Fail("Implement ToString() for the Business object and implement this test");
        }
        [Test]
        public void Test_GetParent()
        {
            //---------------Set up test pack-------------------
            DMSolution dmSolution = new DMSolution();
            UITypeDefinition uiTypeDefinition = new UITypeDefinition();
            dmSolution.UIFilterControlTypes.Add(uiTypeDefinition);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            IModelElement parent = ((IModelElement)uiTypeDefinition).Parent;
            //---------------Test Result -----------------------
            Assert.AreSame(dmSolution, parent);
        }

        [Test]
        public void Test_SetParentExceptionThrown()
        {
            //---------------Set up test pack-------------------
            IModelElement prop = new UITypeDefinition();

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            Exception exceptionThrown = null;
            try
            {
                prop.Parent = new DMSolution();
            }
            catch (Exception ex)
            {
                exceptionThrown = ex;
            }
            //---------------Test Result -----------------------
            Assert.IsNotNull(exceptionThrown);
            Assert.IsInstanceOf(typeof(HabaneroDeveloperException), exceptionThrown);
            StringAssert.Contains
                ("Set the parent of the UITypeDefinition by setting the related Solution object",
                 exceptionThrown.Message);
        }
    }
}